<?php
/* @var $this CitaController */
/* @var $model Cita */

$this->breadcrumbs=array(
	'Mi Perfil'=>array('cliente/view', 'id'=>$model->idCliente),
	'Mis Citas'
);

 $this->widget('zii.widgets.CMenu',array( 
			'htmlOptions' => array( 'class' => 'nav' ),
			'linkLabelWrapper' => 'span',
			'activeCssClass'	=> 'current',
			'items'=>array(
				array('label'=>'Solicitar Cita', 'url'=>array('viewCitaCalendar', 'id'=>$model->idCliente)),		
				array('label'=>'Volver a Perfil', 'url'=>array('cliente/view', 'id'=>$model->idCliente)),
			),
		));


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('cita-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Mis Citas</h1>


<?php echo CHtml::link('Realizar Búsqueda Avanzada','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'cita-grid',
	'dataProvider'=>$model->search($model->idCliente),
	//'rowCssClass' => Yii::app()->baseUrl .'/css/cgridview.css',
	'filter'=>$model,
	'columns'=>array(
		array(
			'class'=>'CButtonColumn',
			'header'=>'Acciones',
			'template'=>'{view}{delete}',
			'deleteConfirmation'=>'Está seguro de que quiere CANCELAR esta CITA?',
			'buttons'=>array(
						'delete'=>array(
									'url'=>'Yii::app()->createUrl("cita/cancel", array("id"=>$data->idCita))',
									'label'=>'Cancelar',
						          ),
					   ),
		),
		array(
			'name'=>'idCita',
			'header'=>'Cita #',
			'value'=>'$data->idCita',
			'htmlOptions' => array(
								'style' => 'width: 50px; text-align: center;',
							 ),
		),
		array(
			'name'=>'idCitaEstado',
			'header'=>'Estado Actual',
			'value'=>'$data->relcitaEstado->estadoActual;',
			'filter'=>CHtml::listData(CitaEstado::model()->findAll(array('order'=>'idCitaEstado ASC')),
																		 'idCitaEstado',
																		 'estadoActual'
																		 ),
			'htmlOptions' => array(
								'style' => 'text-align: center;width:90px;',
							 ),			
		),
		array(
			'name'=>'fecha',
			'header'=>'Fecha',
			'value'=>'$data->fecha',
			'htmlOptions' => array(
								'style' => 'text-align: center;width:80px;',
							 ),	
		),							 
		array(
			'name'=>'hora',
			'header'=>'Hora',
			'value'=>'$data->hora',
			'htmlOptions' => array(
								'style' => 'text-align: center;width:80px;',
							 ),		
		),
		array(
			'name'=>'idDoctor',
			'header'=>'Doctor',
			'value'=>'$data->reldoctor->nombre."  ".$data->reldoctor->apellido1;',
			'filter'=>CHtml::listData(Doctor::model()->findAll(),'idDoctor','fullName'),			
			'htmlOptions' => array(
								'style' => 'text-align: center;width:150px;',
							 ),					
		),				
		'observaciones',
	),
)); ?>
